#include "Geometry.h"

N2F::Iw3D::Rectangle::Rectangle()
{
	return;
}

N2F::Iw3D::Rectangle::Rectangle(CIwFVec2 topleft, CIwFVec2 size)
{
	this->tl = topleft;
	this->tr = CIwFVec2((topleft.x + size.x), topleft.y);
	this->br = CIwFVec2((topleft.x + size.x), (topleft.y + size.y));
	this->bl = CIwFVec2(topleft.x, (topleft.y + size.y));
	this->size = size;

	return;
}

N2F::Iw3D::Rectangle::~Rectangle()
{
	return;
}

bool N2F::Iw3D::Rectangle::intersectedBy(CIwFVec2 pos)
{
	if ((pos.x >= this->tl.x && pos.x <= this->tr.x) && (pos.y >= this->tl.y && pos.y <= this->br.y))
	{
		return(true);
	}

	return(false);
}

bool N2F::Iw3D::Rectangle::intersectedBy(CIwFVec2 pos, CIwFVec2 offset, float scale)
{
//	if ((pos.x >= this->tl.x && pos.x <= ((this->tr.x - this->tl.x) * scale) + this->tl.x) 
//		&& (pos.y >= this->tl.y && pos.y <= ((this->br.y - this->tl.y)* scale) + this->tl.y))
	if ((pos.x >= this->tl.x && pos.x <= ((this->size.x) * scale) + this->tl.x) 
		&& (pos.y >= this->tl.y && pos.y <= ((this->size.y)* scale) + this->tl.y))
	{
		return(true);
	}

	return(false);
}

void N2F::Iw3D::Rectangle::move(float x, float y)
{
	this->tl.x += x;
	this->tl.y += y;
	this->tr = CIwFVec2((this->tl.x + this->size.x), this->tl.y);
	this->br = CIwFVec2((this->tl.x + this->size.x), (this->tl.y + this->size.y));
	this->bl = CIwFVec2(this->tl.x, (this->tl.y + this->size.y));

	return;
}

void N2F::Iw3D::Rectangle::move(CIwFVec2 move)
{
	this->tl = move;
	this->tr = CIwFVec2((this->tl.x + this->size.x), this->tl.y);
	this->br = CIwFVec2((this->tl.x + this->size.x), (this->tl.y + this->size.y));
	this->bl = CIwFVec2(this->tl.x, (this->tl.y + this->size.y));

	return;
}

CIwRect32 N2F::Iw3D::Rectangle::getCIwRect32()
{
	return(CIwRect32((int)this->tl.x, (int)this->tl.y, (int)this->size.x, (int)this->size.y));
}
